package cosc617_blackteam;

import java.math.BigDecimal;

//import java.util.InputMismatchException;

/**
 * 
 * @author sherbahadur This class has customer information, MenuItem information
 * Edited by lsemesky
 *         Client is responsible for checking MenuItem exists
 */
public class Order {
	private Customer customer;
	private CustomerParty party;
	private MenuItem menuItem;
	//we want to copy these things over in case they change after the order has been placed
	private int minutesTilCooked, prepTime;
	private BigDecimal price;
	private String name;
	

	public Order(Customer c, CustomerParty p, MenuItem orderedItem) {
		customer = c;
		party = p;
		menuItem = orderedItem;
		name = menuItem.getName();
		price = menuItem.getPrice();
		minutesTilCooked = menuItem.getPrepTime();
		prepTime = minutesTilCooked;
		
	}
	public Order(MenuItem orderedItem, CustomerParty p){
		this(null, p, orderedItem);
	}
	public CustomerParty getCustomerParty(){
		return party;
	}
	
	public void decrementCookTime(){
		minutesTilCooked--;
		
	}
	
	public int prepTime(){
		return prepTime;
	}
	public String name(){
		return name;
	}
	public BigDecimal price(){
		return price;
	}
	
	public boolean isReady(){
		return minutesTilCooked <= 0;
	}
	
	public Customer customer() {
		return customer;
	}

/*	public MenuItem orderItem() {
		return menuItem;
	}*/
	
	public String toString(){
		return  "Party ID: " + party.getID() + " of size "+ party.getSize() +
				" Ordered Item: " + name() + " time left til finished: " + minutesTilCooked;
		
	}
	
	public Order copy(){
		return new Order(this.menuItem, new CustomerParty(party.getID()));
	}

}
